<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>菜单列表</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/layui/css/layui.css">
<link rel="stylesheet" href="$request.getContextPath()/resources/bootstrap-table/css/bootstrap-table.min.css">
<link rel="stylesheet" href="$request.getContextPath()/resources/cws/system/menu/list.css" />
</head>
<body>
	<div class="container-fluid">
		<div class="header"></div>
		<div class="searchform">
			<form class="form-horizontal" role="form" action="">
				<div class="form-group">
					<label for=parentMenuId class="col-sm-1 control-label">顶级菜单</label>
					<div class="col-sm-2">
						<select class="form-control" id="parentMenuSelect" name="parentMenuId" placeholder="请输入菜单">
						    <option value="0">全部</option>
							#foreach($menu in $topMenus)
					           <option value="$!menu.menuId">$!menu.menuName</option>
					        #end
						</select>
					</div>
					<label for="menuName" class="col-sm-1 control-label">菜单名称</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" name="menuName" placeholder="请输入菜单名称">
					</div>
					<div class="col-sm-2">
						<button type="button" onclick="queryMenu()" class="btn btn-default">查询</button>
					</div>
				</div>
			</form>
		</div>
		<div id="toolbar">
			#if($shiro.hasPermission('system:menu:add'))
				<button type="button" class="btn btn-default btn-sm" onclick="addMenu()"><span class="glyphicon glyphicon-plus"></span>添加</button>
			#end
			#if($shiro.hasPermission('system:menu:export'))
				#if($model.has('sys_menu'))
					<a type="button" class="btn btn-default btn-sm" href="$request.getContextPath()/common/export/excel/sys_menu/xlsx"><span class="glyphicon glyphicon-export"></span>导出</a>
				#end
			#end
			<!--#if($shiro.hasPermission('system:menu:statistics'))
				<button type="button" class="btn btn-default btn-sm" onclick="menuStatistics()"><span class="glyphicon glyphicon-star"></span>统计</button>
			#end-->
		</div>
		<table id="menuTable" 
		    data-toolbar="#toolbar" 
		    data-show-refresh="true"
			data-search="false" 
			data-show-toggle="true" 
			data-show-columns="true"
			data-show-export="true" 
			data-id-field="id" 
			data-show-export="true"
			data-pagination="true" 
			data-query-params="queryParams"
			data-query-type="limit" 
			data-show-footer="false"
			data-click-to-select="true" 
			data-single-select="false"
			data-striped="true" 
			data-method="get"
			data-url="$request.getContextPath()/system/menu/page"
			data-side-pagination="server" 
			data-page-list="[10, 25, 50, 100, ALL]"
			data-show-pagination-switch="true" 
			data-id-field="userId"
			data-search-on-enter-key="true" 
			data-pagination-v-align="bottom"
			data-show-pagination-switch="true">
		</table>
	</div>
</body>
<script src="$request.getContextPath()/resources/jquery/jquery-3.1.0.min.js"></script>
<script src="$request.getContextPath()/resources/bootstrap/js/bootstrap.min.js"></script>

<script type="text/javascript" src="$request.getContextPath()/resources/layer/layer.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/layui.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/lay/modules/element.js"></script>

<script type="text/javascript" src="$request.getContextPath()/resources/bootstrap-table/js/bootstrap-table.min.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>

<script type="text/javascript">
	function operateFormatter(value, row, index){
		//用户角色权限按钮
		var menuPermissionButtons=[];
		var menuViewPermission="$shiro.hasPermission('system:menu:view')";
		if(menuViewPermission&&menuViewPermission=="true"){
			menuPermissionButtons.push('<button type="button" class="btn btn-default btn-sm menuDetail"><span class="glyphicon glyphicon-eye-open"></span>查看</button>');
		}
		var menuEditPermission="$shiro.hasPermission('system:menu:edit')";
		if(menuEditPermission&&menuEditPermission=="true"){
			menuPermissionButtons.push('<button type="button" class="btn btn-default btn-sm editMenu"><span class="glyphicon glyphicon-edit"></span>编辑</button>');
		}
		var menuDeletePermission="$shiro.hasPermission('system:menu:delete')";
		if(menuDeletePermission&&menuDeletePermission=="true"){
			menuPermissionButtons.push('<button type="button" class="btn btn-default btn-sm deleteMenu"><span class="glyphicon glyphicon-trash"></span>删除</button>');
		}
		console.log(row);
		if(row.parentMenuId!=0){
			var roleMenuPermissionPermission="$shiro.hasPermission('system:menu:permission')";
			if(roleMenuPermissionPermission&&roleMenuPermissionPermission=="true"){
				menuPermissionButtons.push('<button type="button" class="btn btn-default btn-sm menuPermission"><span class="glyphicon glyphicon-leaf"></span>权限</button>');
			}
		}else{
			var roleSubMenuPermission="$shiro.hasPermission('system:menu:leaf')";
			if(roleSubMenuPermission&&roleSubMenuPermission=="true"){
				menuPermissionButtons.push('<button type="button" class="btn btn-default btn-sm subMenu"><span class="glyphicon glyphicon-th-large"></span>菜单</button>');
			}
		}
		return menuPermissionButtons.join('');
	}
</script>
<script type="text/javascript" src="$request.getContextPath()/resources/cws/system/menu/list.js"></script>
</html>
#parse("/portal/account/footer2.html")